{% extends 'base.html' %}
{% block title %}借阅历史 - Local Library{% endblock %}
{% block content %}
    <h1>我的借阅历史</h1>
    {% if bookinstance_list %}
        <div class="cards-row" style="flex-wrap:wrap;gap:18px;">
        {% for inst in bookinstance_list %}
            <div class="info-card" style="min-width:220px;max-width:320px;flex:1 1 220px;">
                <div class="info-card-title">📖 <a href="{% url 'book-detail' inst.book.pk %}">{{ inst.book.title }}</a></div>
                <div class="info-item"><b>作者：</b>{{ inst.book.author }}</div>
                <div class="info-item"><b>借阅日期：</b>{{ inst.imprint }}</div>
                <div class="info-item"><b>到期日：</b>{{ inst.due_back }}</div>
                <div class="info-item"><b>状态：</b>{% if inst.status == 'a' %}已归还{% elif inst.status == 'o' %}借阅中{% elif inst.status == 'm' %}维护中{% elif inst.status == 'r' %}已预订{% endif %}</div>
            </div>
        {% endfor %}
        </div>
        {% if is_paginated %}
            <div class="pagination">
                {% if page_obj.has_previous %}
                    <a href="?page={{ page_obj.previous_page_number }}">上一页</a>
                {% endif %}
                <span>第 {{ page_obj.number }} 页，共 {{ page_obj.paginator.num_pages }} 页</span>
                {% if page_obj.has_next %}
                    <a href="?page={{ page_obj.next_page_number }}">下一页</a>
                {% endif %}
            </div>
        {% endif %}
    {% else %}
        <p>暂无借阅历史。</p>
    {% endif %}
{% endblock %} 